package com.heima.wemedia.controller.v1;

import com.heima.client.article.IArticleClient;
import com.heima.model.common.comment.dtos.CommentDetailPageDto;
import com.heima.model.common.comment.dtos.CommentLikeDto;
import com.heima.model.common.comment.dtos.CommentManagePageDto;
import com.heima.model.common.comment.dtos.CommentRepayDto;
import com.heima.model.common.dtos.CommentUpdateStatusDto;
import com.heima.model.common.dtos.ResponseResult;
import com.heima.wemedia.service.CommentManageService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * Description: 文章评论管理
 * Author: Wzh
 * Date: 2024/8/1
 */
@RestController
@RequestMapping("/api/v1/comment/manage")
@Slf4j
public class CommentManageController {
    @Autowired
    private CommentManageService commentManageService;

    /**
     * 评论管理查询
     * @param commentDto
     * @return
     */
    @PostMapping("/find_news_comments")
    public ResponseResult findComments(@RequestBody CommentManagePageDto commentDto){
        log.info("评论管理查询接收参数:{}",commentDto);
        return commentManageService.findComments(commentDto);
    }

    /**
     * 打开评论/关闭
     * @return
     */
    @PostMapping("/update_comment_status")
    public ResponseResult updateCommentStatus(@RequestBody CommentUpdateStatusDto statusDto){
        log.info("打开/关闭文章ID为{}的评论",statusDto.getArticleId());
        return commentManageService.updateStatus(statusDto);
    }

    /**
     * 查看文章评论详情
     * @return
     */
    @PostMapping("/list")
    public ResponseResult listCommentDetail(@RequestBody CommentDetailPageDto detailPageDto){
        log.info("查询文章评论详情参数:{}",detailPageDto);
        return commentManageService.listCommentDetail(detailPageDto);
    }


    /**
     * 作者回复评论
     * @param repayDto
     * @return
     */
    @PostMapping("/comment_repay")
    public ResponseResult repayComment(@RequestBody CommentRepayDto repayDto){
        log.info("回复文章评论：{}",repayDto);
        return commentManageService.repayComment(repayDto);
    }

    /**
     * 评论点赞
     * @param likeDto
     * @return
     */
    @PostMapping("/like")
    public ResponseResult likeComment(@RequestBody CommentLikeDto likeDto){
        log.info("点赞评论参数：{}",likeDto);
        return commentManageService.likeComment(likeDto);
    }
}

